package cn.xval.ft.core;

import cn.xval.ft.core.marketdata.MarketDataService;
import com.google.protobuf.Empty;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class Main {
    private final static int servingPort = 10240;
    public static void main(String[] args) throws IOException, InterruptedException {
        System.out.println("Hello world!");
        log.info("启动 CTP 对接服务 ...");
        startGrpc();
    }


    private static void startGrpc() throws InterruptedException, IOException {
        Server server = ServerBuilder.forPort(servingPort)
                .addService(new MarketDataService())
                .build()
                .start();
        log.info("CTP 对接服务端口: " + servingPort);
//        Server server = ServerBuilder.forPort(port)
//                .addService(new Authentication())
//                .addService(new Digital())
//                .addService(new VehicleStream())
//                .build()
//                .start();
//        log.info("GRPC Listening at: " + port);
        server.awaitTermination();
    }

    static {
        System.loadLibrary("thostmduserapi_se");
        System.loadLibrary("thosttraderapi_se");
        System.loadLibrary("wrap");
    }
}